<template>
	<view class="report-page">
		<u-navbar title="财务申报" back-icon-color="#fff" title-color="#fff" :background="background">
			<view class="navbar-right" slot="right">
				<view class="dot-box right-item" @click="historyList">
					<u-image shape="square" ref="uImage" width="40" height="40" src="../../static/icon/history-icon.png" mode="aspectFill">
					</u-image>
				</view>
			</view>
		</u-navbar>
		
		<!-- 食材部分 -->
		<view class="" v-show="setp == 'one'">
			<view class="report-total bg-white mb30" v-if="food_id == ''">
				<view class="row-between">
					<view class="total-title">
						出勤
					</view>
					<view>
						<u-checkbox-group>
							<u-checkbox v-model="postData.chuqin">是</u-checkbox>
						</u-checkbox-group>
					</view>
				</view>
			</view>
			
			<view class="report-total bg-white">
				<view class="row-between" @click="showChange">
					<view class="total-title">
						上报日期
					</view>
					<view class="total-input u-text-right">
						{{postData.date}}
					</view>
				</view>
			</view>
			
			<!-- 日期选择 -->
			<u-calendar v-model="dateShow" ref="calendar" @change="dateChange" :mode="dateMode"
				 :active-bg-color="activeBgColor" :btn-type="btnType"
			>
			</u-calendar>
			
			<!-- 总支出 -->
			<!-- <view class="report-total bg-white">
				<view class="row-between">
					<view class="total-title">
						食材总支出
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.price_week" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
			</view> -->
			
			<!-- 秦隆提供的食材支出 -->
			<view class="report-content bg-white">
				<view class="row-between total-title" @click="clickDevelop" data-index="food_is_develop">
					<view class="">
						食材支出（秦隆）
					</view>
					<view class="">
						<u-icon :name="food_is_develop ? 'arrow-up' : 'arrow-down'" color="#2045fc" size="16px" ></u-icon>
					</view>
				</view>
				
				<view class="" v-show="food_is_develop">
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">蔬菜</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.vegetables_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">食用油</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.oil_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">调味品</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.condiments_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">大米</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.rice_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">面粉</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.flour_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">猪肉</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.meat_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">鸡肉</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.chicken_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">牛羊肉</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.beef_mutton_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">鸡蛋</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.egg_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">干货</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.dry_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">水果</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.fruit_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">五谷</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.grain_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">牛奶</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.milk_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">辅食</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.side_dish_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">其他</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.other_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<!-- <view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">伙食日劳务费</text>
						</view>
						<view class="total-input">
							<u-input :disabled="true" :inputAlign="inputAlign" v-model="postData.food.labor_price" placeholder="伙食日劳务费" :type="type" :border="border" />
						</view>
					</view> -->
					
				</view>
			</view>
			
			<!-- 非秦隆提供的食材支出 -->
			<view class="report-content bg-white">
				<view class="row-between total-title" @click="clickDevelop" data-index="out_food_is_develop">
					<view class="">
						食材支出（非秦隆）
					</view>
					<view class="">
						<u-icon :name="out_food_is_develop ? 'arrow-up' : 'arrow-down'" color="#2045fc" size="16px" ></u-icon>
					</view>
				</view>
				
				<view class="" v-show="out_food_is_develop">
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">未从秦隆下单物品</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.no_ql_order_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">外购馒头</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.steamed_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
					
					<view class="row-between content-items">
						<view>
							<text class="required-color">*</text>
							<text class="ml10">外购面条</text>
						</view>
						<view class="total-input">
							<u-input :inputAlign="inputAlign" v-model="postData.food.noodles_price" placeholder="请输入金额" :type="type" :border="border" />
						</view>
					</view>
				</view>
			</view>
		
			<!-- 提交按钮 -->
			<view class="submit-btn white" @click="goSetp" data-type="two">
				<view class="submit-btn-content row-center">
					下一步
				</view>
			</view>
		</view>
		
		
		<!-- 秦隆产生的间接成本 -->
		<!-- <view class="report-content bg-white">
			<view class="row-between total-title" @click="clickDevelop" data-index="other_is_develop">
				<view class="">
					间接成本（秦隆）
				</view>
				<view class="">
					<u-icon :name="other_is_develop ? 'arrow-up' : 'arrow-down'" color="#2045fc" size="16px" ></u-icon>
				</view>
			</view>
			
			<view class="" v-show="other_is_develop">
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">后勤小件快消</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.logistics_a_kuaixiao_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
				
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">后勤小件厨具</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.logistics_a_chuju_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
				
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">办公用品</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.office_supplies_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
				
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">杂费日劳务费</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.za_fee_labor_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
				
				
			</view>
		</view> -->
		
		<!-- 非秦隆间接成本 -->
		<!-- <view class="report-content bg-white">
			<view class="row-between total-title" @click="clickDevelop" data-index="out_other_is_develop">
				<view class="">
					间接成本（非秦隆）
				</view>
				<view class="">
					<u-icon :name="out_other_is_develop ? 'arrow-up' : 'arrow-down'" color="#2045fc" size="16px" ></u-icon>
				</view>
			</view>
			
			<view class="" v-show="out_other_is_develop">
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">学生奖品</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.stu_prize_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
				
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">维修补充</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.maintenance_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
				
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">员工房租</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.ren_rent_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
				
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">水电费</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.electricity_water_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
				
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">甲醇、燃气费</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.fuel_gas_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
				
				<view class="row-between content-items">
					<view>
						<text class="required-color">*</text>
						<text class="ml10">其他</text>
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.food.indrect_other_price" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
			</view>
		</view> -->
		
		
		<!-- 杂费支出 -->
		<view class="" v-show="setp == 'two'">	
			<!-- <view class="report-total bg-white">
				<view class="row-between">
					<view class="total-title">
						杂费总支出
					</view>
					<view class="total-input">
						<u-input :inputAlign="inputAlign" v-model="postData.other_price_week" placeholder="请输入金额" :type="type" :border="border" />
					</view>
				</view>
			</view> -->
			
			<view class="report-other bg-white">
				<view class="total-title">
					杂费支出
				</view>
				
				<view class="item-box row-between" v-for="(item, index) in postData.otherList" :key="index">
					<view class="item-child-one row">
						<text class="required-color mr10">*</text>
						<u-input inputAlign="left" v-model="item.spending" placeholder="名称" type="text" :border="border" />
					</view>
					<view class="row">
						<view>
							<u-input :inputAlign="inputAlign" v-model="item.actual_amount" placeholder="请输入金额" :type="type" :border="border" />
						</view>
						<view class="delete" @click="delItem(item)">
							删除
						</view>
					</view>
					
				</view>
				<view class="other-btn row-center" @click="addItem">
					<u-icon name="plus-circle" color="#2045fc" size="20px" ></u-icon>
					<text class="ml20">其他杂费</text>
				</view>
			</view>
			
			<!-- 提交按钮 -->
			<view>
				<view class="submit-btn white" @click="goSetp" data-type="one">
					<view class="submit-btn-content row-center">
						上一步
					</view>
				</view>
				
				<view class="submit-btn white" @click="submitBtn">
					<view class="submit-btn-content row-center">
						提交
					</view>
				</view>
			</view>
		</view>
				
		<!-- 删除其他杂费 -->
		<u-modal v-model="deleteShow" :content="otherDelContent" @confirm="delConfirm" :show-cancel-button="true"></u-modal>
	</view>
</template>
 
<script>
	export default {
		data() {
			return {
				type: 'digit',
				border: false,
				inputAlign: 'right',
				background: {
					backgroundColor: '#2165F7',
				},
				
				food_id: '',
				
				deleteShow: false,
				otherDelContent: '确认删除该杂费项？',
				
				otherId: 0,
				delOtherId: '',
				
				dateShow: false,
				dateMode: 'date',
				activeBgColor: '#2165F7',
				btnType: 'primary',
				
				food_is_develop: false,
				out_food_is_develop: false,
				other_is_develop: false,
				out_other_is_develop: false,
				setp: 'one',
				
				postData: {
					chuqin: true,
					date: '',
					food: {
						price_week: '',
						
						vegetables_price: '',
						oil_price: '',
						condiments_price: '',
						rice_price: '',
						flour_price: '',
						meat_price: '',
						chicken_price: '',
						beef_mutton_price: '',
						egg_price: '',
						dry_price: '',
						fruit_price: '',
						grain_price: '',
						milk_price : '',
						side_dish_price : '',
						other_price : '',
						labor_price : '',
						no_ql_order_price : '',
						steamed_price: '',
						noodles_price: '',
						// logistics_a_kuaixiao_price : '',
						// logistics_a_chuju_price : '',
						// office_supplies_price : '',
						// za_fee_labor_price : '',
						// stu_prize_price : '',
						// maintenance_price : '',
						// ren_rent_price : '',
						// electricity_water_price: '',
						// fuel_gas_price: '',
						// indrect_other_price: '',
					},
					otherList: [
						{
							spending :"秦隆杂费",
							actual_amount:"",
						},
						{
							spending:"维修费",
							actual_amount:"",
						},
						{
							spending:"奖品费",
							actual_amount:"",
						}
					],
					other_price_week: '', // 杂费总支出
				}
			
			}
		},
		onLoad(options) {
			var currentDate = new Date(),
			year = currentDate.getFullYear(),
			month = currentDate.getMonth() + 1,
			day = currentDate.getDate();
			
			this.postData.date = year + '-' + month + '-' + day;
			
			if(options.id != undefined) {
				this.food_id = options.id;
				this.getDeatilFunc();
			}
		},
		methods: {
			showChange() {
				this.dateShow = !this.dateShow;
			},
			dateChange(e) {
				this.postData.date = e.result;
			},
			getDeatilFunc: function() {
				let _this = this;
				let post_params = {
					food_id: _this.food_id,
				};
				_this.$u.post('/api/finance/getFoodweek', post_params).then(res => {
					let _indirect = res.indirect;
					let _food = res.food;
					let new_indirect = [];
					
					_indirect.forEach(function(item,index) {
						let _tmp = {
							spending: item.spending,
							actual_amount: item.actual_amount,
						};
						new_indirect.push(_tmp);
					})
					
					_this.postData = {
						date: _food.date,
						food: {
							vegetables_price: _food.vegetables_price,
							oil_price: _food.oil_price,
							condiments_price: _food.condiments_price,
							rice_price: _food.rice_price,
							flour_price: _food.flour_price,
							meat_price: _food.meat_price,
							chicken_price: _food.chicken_price,
							beef_mutton_price: _food.beef_mutton_price,
							egg_price: _food.egg_price,
							dry_price: _food.dry_price,
							fruit_price: _food.fruit_price,
							grain_price: _food.grain_price,
							milk_price : _food.milk_price,
							side_dish_price : _food.side_dish_price,
							other_price : _food.other_price,
							labor_price : _food.labor_price,
							no_ql_order_price : _food.no_ql_order_price,
							steamed_price: _food.steamed_price,
							noodles_price: _food.noodles_price,
						},
						otherList: _indirect,
					}
				});
			},
			historyList: function() {
				uni.navigateTo({
					url: '/pages/finance/reportList'
				})
			},
			goSetp: function(e) {
				let _type = e.currentTarget.dataset.type;
				
				if(_type == 'two' && this.checkOneData()) {
					this.setp = _type;
				} else if(_type == 'one') {
					this.setp = _type;
				}
			},
			addItem() {
				let add = {
					index_id: parseInt(this.otherId)+1,
					spending: '',
					actual_amount: '',
				}
				this.postData.otherList.push(add)
				this.otherId = parseInt(this.otherId)+1
			},
			delConfirm() {
				let _this = this;
				_this.postData.otherList = _this.postData.otherList.filter((i) => {
					return i != _this.delOtherId
				})
			},
			delItem(item) {
				this.delOtherId = item;
				this.deleteShow = true;
			},
			checkOneData() {
				let _this = this;
				let {
					food
				} = _this.postData;
				
				let total_amount = 0;
				// if(!_this.isNull(food.price_week)) {
				// 	uni.showToast({
				// 		title: '请输入食材总支出金额',
				// 		icon: "none"
				// 	})
				// 	return false;
				// }
			
				// for(let key in food){
				// 	if(!_this.isNull(food[key])) {
				// 		if(key == 'price_week') {
				// 			uni.showToast({
				// 				title: '请输入食材总支出金额',
				// 				icon: "none"
				// 			})
				// 		} else {
				// 			let err_title = '';
				// 			console.log(key);
				// 			if(key == 'vegetables_price') err_title = "蔬菜" 
				// 			else if(key == 'oil_price') err_title = "食用油" 
				// 			else if(key == 'condiments_price') err_title = "调味品" 
				// 			else if(key == 'rice_price') err_title = "大米" 
				// 			else if(key == 'flour_price') err_title = "面粉" 
				// 			else if(key == 'meat_price') err_title = "猪肉" 
				// 			else if(key == 'chicken_price') err_title = "鸡肉" 
				// 			else if(key == 'beef_mutton_price') err_title = "牛羊肉" 
				// 			else if(key == 'egg_price') err_title = "鸡蛋" 
				// 			else if(key == 'dry_price') err_title = "干货" 
				// 			else if(key == 'fruit_price') err_title = "水果" 
				// 			else if(key == 'grain_price') err_title = "五谷" 
				// 			else if(key == 'milk_price') err_title = "牛奶" 
				// 			else if(key == 'side_dish_price') err_title = "辅食" 
				// 			else if(key == 'other_price') err_title = "其他" 
				// 			else if(key == 'no_ql_order_price') err_title = "非秦隆下单物品" 
				// 			else if(key == 'steamed_price') err_title = "外购馒头" 
				// 			else if(key == 'noodles_price') err_title = "外购面条" 
				// 			uni.showToast({
				// 				title: '食材支出'+err_title+'为空，请检查',
				// 				icon: "none"
				// 			})
				// 		}
						
				// 		return false;
				// 	}
				// }
				
				let rice_price = food.rice_price == '' ? 0 : food.rice_price;
				let oil_price = food.oil_price == '' ? 0 : food.oil_price;
				let flour_price = food.flour_price == '' ? 0 : food.flour_price;
				let steamed_price = food.steamed_price == '' ? 0 : food.steamed_price;
				let noodles_price = food.noodles_price == '' ? 0 : food.noodles_price;
				let condiments_price = food.condiments_price == '' ? 0 : food.condiments_price;
				let dry_price = food.dry_price == '' ? 0 : food.dry_price;
				let meat_price = food.meat_price == '' ? 0 : food.meat_price;
				let chicken_price = food.chicken_price == '' ? 0 : food.chicken_price;
				let egg_price = food.egg_price == '' ? 0 : food.egg_price;
				let fruit_price = food.fruit_price == '' ? 0 : food.fruit_price;
				let vegetables_price = food.vegetables_price == '' ? 0 : food.vegetables_price;
				let beef_mutton_price = food.beef_mutton_price == '' ? 0 : food.beef_mutton_price;
				let grain_price = food.grain_price == '' ? 0 : food.grain_price;
				let milk_price = food.milk_price == '' ? 0 : food.milk_price;
				let side_dish_price = food.side_dish_price == '' ? 0 : food.side_dish_price;
				let other_price = food.other_price == '' ? 0 : food.other_price;
				
				let no_ql_order_price = food.no_ql_order_price == '' ? 0 : food.no_ql_order_price;
				// let logistics_a_kuaixiao_price = food.logistics_a_kuaixiao_price == '' ? 0 : food.logistics_a_kuaixiao_price;
				// let logistics_a_chuju_price = food.logistics_a_chuju_price == '' ? 0 : food.logistics_a_chuju_price;
				// let office_supplies_price = food.office_supplies_price == '' ? 0 : food.office_supplies_price;
				// let za_fee_labor_price = food.za_fee_labor_price == '' ? 0 : food.za_fee_labor_price;
				// let stu_prize_price = food.stu_prize_price == '' ? 0 : food.stu_prize_price;
				// let maintenance_price = food.maintenance_price == '' ? 0 : food.maintenance_price;
				// let ren_rent_price = food.ren_rent_price == '' ? 0 : food.ren_rent_price;
				// let electricity_water_price = food.electricity_water_price == '' ? 0 : food.electricity_water_price;
				// let fuel_gas_price = food.fuel_gas_price == '' ? 0 : food.fuel_gas_price;
				// let indrect_other_price = food.indrect_other_price == '' ? 0 : food.indrect_other_price;
				
				// 计算总的秦隆伙食费
				total_amount = parseFloat(rice_price) + parseFloat(oil_price)
				+ parseFloat(flour_price)  
				+ parseFloat(condiments_price) + parseFloat(dry_price) + parseFloat(meat_price) 
				+ parseFloat(chicken_price) + parseFloat(egg_price) + parseFloat(fruit_price) 
				+ parseFloat(vegetables_price) + parseFloat(beef_mutton_price) + parseFloat(grain_price) 
				+ parseFloat(milk_price) + parseFloat(side_dish_price) + parseFloat(other_price); 
				
				var food_labor_price = (parseFloat(total_amount) * 0.1).toFixed(2);
				food.labor_price = parseFloat(food_labor_price);
				
				total_amount += parseFloat(food_labor_price);
				total_amount += parseFloat(no_ql_order_price) + parseFloat(steamed_price) + parseFloat(noodles_price);
				// + parseFloat(logistics_a_kuaixiao_price) 
				// + parseFloat(logistics_a_chuju_price) + parseFloat(office_supplies_price) + parseFloat(za_fee_labor_price) 
				// + parseFloat(stu_prize_price) + parseFloat(maintenance_price) + parseFloat(ren_rent_price) 
				// + parseFloat(electricity_water_price) + parseFloat(fuel_gas_price) + parseFloat(indrect_other_price); 
				
				if(isNaN(total_amount)) {
					total_amount = 0;
				}
				
				food.price_week = parseFloat(total_amount).toFixed(2);
				
				// if(parseFloat(total_amount).toFixed(2) != parseFloat(food.price_week).toFixed(2)) {
				// 	uni.showToast({
				// 		title: '费用总和与总支出不一致，请重新检查各项金额',
				// 		icon: "none"
				// 	})
				// 	return false;
				// }
				
				return true;
				
			},
			// 校验数据
			submitBtn() {
				let _this = this;
				
				let tips_str = _this.checkOther();
				
				if(tips_str != '') {
					uni.showToast({
						title: tips_str,
						icon: "none"
					})
					return false;
				}
				
				uni.showModal({
					title: '提示',
					content: '您确定提交该账单吗？',
					cancelText: "取消", // 取消按钮的文字  
					confirmText: "确定", // 确认按钮文字  
					showCancel: true, // 是否显示取消按钮，默认为 true
					success: (res) => {
						if(res.confirm) {  
							_this.postFunc();
						} else {  
							console.log('else', res)
						}  
					} 
				})
				
			},
			
			// 数据提交
			postFunc: function() {
				let postData = {};
				postData.food = this.postData.food;
				postData.other = this.postData.otherList;
				
				// 修改财务申报
				if(this.food_id != ''){
					postData.food_id = this.food_id;
					this.$u.post('api/finance/updateFoodprice', postData).then(res => {
						uni.redirectTo({
							url: '/pages/finance/reportList'
						})
					})
				} else {
					postData.chuqin = this.postData.chuqin == true ? 1 : 0;
					postData.date = this.postData.date;
					
					this.$u.post('api/finance/addFoodprice', postData).then(res => {
						uni.redirectTo({
							url: '/pages/finance/reportList'
						})
					})
				}
				
			},
			checkOther: function() {
				let _this = this;
				let _otherList = _this.postData.otherList;
				let _tips_str = '';
				let total_amount = 0;
				let other_price_week = _this.postData.other_price_week;
				
				
				// if(!_this.isNull(other_price_week)) {
				// 	_tips_str = '请输入杂费总支出金额';
				// 	return _tips_str;
				// }
				
				try{
					_otherList.forEach(function(item,index) {
						if(_this.isNull(item.spending) && !_this.isNull(item.actual_amount)) {
							_tips_str = '杂费中【'+item.spending + '】价格为空';
							throw new Error("ending");//报错，就跳出循环
						}
						
						total_amount += parseFloat(item.actual_amount);
					})
				}catch(e){
					if(e.message == "ending"){
						console.log('catch',_tips_str) ;
						return _tips_str;
					}
				}
				
				// if(parseFloat(total_amount).toFixed(2) != parseFloat(_this.postData.other_price_week).toFixed(2)) {
				// 	_tips_str = '费用总和与杂费总支出不一致，请重新检查各项金额';
				// }
				
				return _tips_str;
			},
			clickDevelop: function(e) {
				let _this = this;
				let _index = e.currentTarget.dataset.index;
				_this[`${_index}`] = !_this[`${_index}`];
				
				console.log(_index)
			},
			isNull(value) {
				if(value == '' || value == 0 || value == undefined) {
					return false;
				}
				return true;
			}
		}
	}
</script>
 
<style lang="scss">
	page {
		background-color: #f6f6f6;
		padding-bottom: 60rpx;
	}
	.report-page {
		.navbar-right {
			margin-right: 24rpx;
			display: flex;
		}
		
		.right-item {
			margin: 0 12rpx;
			position: relative;
			color: #ffffff;
			display: flex;
		}
		
		.total-title {
			position: relative;
			font-size: 32rpx;
			font-weight: bold;
			padding: 0 20rpx;
			
			&:before {
				content: "";
				position: absolute;
				top: 0;
				bottom: 0;
				left: 0;
				margin: auto 0;
				width: 6rpx;
				height: 30rpx;
				background-color: #2045fc;
			}
		}
		
		.total-input {
			width: 340rpx;
		}
		
		.report-total {
			padding: 10rpx 20rpx;
			
			.total-title {
				padding: 0 0;
				
				&:before {
					left: -20rpx;
				}
			}
			
			.total-input {
				padding-right: 10rpx;
			}
		}
		
		.report-content {
			padding: 20rpx 0;
			margin-top: 30rpx;
			
			.content-items {
				padding: 16rpx 30rpx;
				border-bottom: 2rpx solid #f6f6f6;
				
				&:last-child {
					border-bottom: none;
				}
			}
		}
		
		.report-other {
			padding: 10rpx 0;
			// margin-top: 30rpx;
			
			.item-box{
				padding: 16rpx 30rpx;
				border-bottom: 2rpx solid #f6f6f6;
				
				.item-child-one {
					width: 30%;
					position: relative;
					&:after {
						content: "";
						position: absolute;
						top: 0;
						bottom: 0;
						right: -20rpx;
						margin: auto 0;
						width: 2rpx;
						height: 60rpx;
						background-color: #F6F6F6F6
					}
				}
				
				.delete{
					border: 2rpx solid #E89C38;
					border-radius: 4rpx;
					padding: 5rpx 10rpx;
					margin-left:60rpx;
					color:#E89C38;
					width: 20%;
					text-align: center;
				}
			}
			
			.other-btn {
				padding: 20rpx;
				color: #2045fc;
			}
		}
		
		.submit-btn {
			margin: 30rpx;
			.submit-btn-content {
				width: 100%;
				padding: 20rpx;
				background-color: #2045fc;
				border-radius: 50rpx;
				box-shadow: 0px 3px 10px rgba(32, 69, 252, 0.5);
			}
		}
		
	}
	
</style>